home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2004 #6 / Amiga Plus CD - 2004 - No. 06.iso / AmiSoft / Dev / src / Apfelberge.lha / Apfelberge / tgi.h < prev   
C/C++ Source or Header  |  2004-04-28  |  1KB  |  75 lines

  1. /* CC65's tiny graphic interface API */
  2. /* 030/25: */
  3. /* s 37.86 */
  4. /* i 24.86 */
  5. /* f 19.28 */
  6. /* 8 12.12 */
  7.  
  8. #ifndef _TGI_H
  9. #define _TGI_H
  10.  
  11. #ifndef __SASC
  12. #include <proto/exec.h>
  13. struct GfxBase *GfxBase;
  14. struct IntuitionBase *IntuitionBase;
  15. #endif
  16. #include <proto/graphics.h>
  17. #include <proto/intuition.h>
  18.  
  19. const TGI_MODE_160_200_4;
  20.  
  21. struct Window *window;
  22. struct RastPort *rp;
  23.  
  24. void tgi_load(int mode)
  25. {
  26. #ifndef __SASC
  27. GfxBase=(struct GfxBase *)OldOpenLibrary("graphics.library");
  28. IntuitionBase=(struct IntuitionBase *)OldOpenLibrary("intuition.library");
  29. #endif
  30. }
  31.  
  32. void tgi_init(void)
  33. {
  34. static struct NewWindow mywindow={0, 0, 160, 200, 0, 1, CLOSEWINDOW, WINDOWDRAG|ACTIVATE,
  35. NULL, NULL, "Apfelberge    ", NULL, NULL, 0, 0, 0, 0, WBENCHSCREEN};
  36. #ifdef __JOYSTICK__
  37. extern p;
  38.  
  39. mywindow.Title[11]='(';
  40. mywindow.Title[12]='0'+p;
  41. mywindow.Title[13]=')';
  42. #endif
  43. window=OpenWindow(&mywindow);
  44. rp=window->RPort;
  45. }
  46.  
  47. __inline void tgi_clear(void)
  48. {
  49. ClearScreen(rp);
  50. }
  51.  
  52. const palette[]={0, 2, 3, 1};
  53.  
  54. __inline void tgi_setcolor(int color)
  55. {
  56. SetAPen(rp, palette[color]);
  57. }
  58.  
  59. __inline void tgi_line(int u, int v, int u1, int v1)
  60. {
  61. Move(rp, u, v);
  62. Draw(rp, u1, v1);
  63. }
  64.  
  65. void tgi_unload(void)
  66. {
  67. CloseWindow(window);
  68. #ifndef __SASC
  69. CloseLibrary((struct Library *) IntuitionBase);
  70. CloseLibrary((struct Library *) GfxBase);
  71. #endif
  72. }
  73.  
  74. #endif
  75.